package com.fancy.learncenter.ui.adapter;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.fancy.learncenter.R;
import com.fancy.learncenter.bean.CartoonContructSatisticsesBean;
import com.fancy.learncenter.bean.CartoonStudentStatisBean;
import com.fancy.learncenter.common.JumpIntentKey;
import com.fancy.learncenter.ui.activity.CartoonQuestionTypeActivity;
import com.fancy.learncenter.ui.adapter.base.CommonRecycleViewAdapter;
import com.fancy.learncenter.ui.adapter.base.CustomViewHold;
import com.fancy.learncenter.ui.callback.AlbumImpl;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by shiweiwei on 2017/12/28.
 */

public class CartoonStaticsAdapter extends CommonRecycleViewAdapter<CartoonContructSatisticsesBean> {
    private JumpIntentKey.QUESTION_ENTER_TYPE type;


    public void setListener(AlbumImpl listener) {
        this.listener = listener;
    }

    private AlbumImpl listener;

    public CartoonStaticsAdapter(Context mContext, JumpIntentKey.QUESTION_ENTER_TYPE type, List<CartoonContructSatisticsesBean> itemDatas) {
        super(mContext, R.layout.cartoon_statics_item, itemDatas);
        this.type = type;
    }

    @Override
    public void bindView(CustomViewHold customViewHold, CartoonContructSatisticsesBean item, final int position) {
        TextView questionType = customViewHold.getView(R.id.question_type);
        TextView questionStatus = customViewHold.getView(R.id.question_status);
        TextView question_num = customViewHold.getView(R.id.question_num);
        ImageView right_arrow = customViewHold.getView(R.id.right_arrow);
        switch (type) {
            case DO_WORK:
            case CONTINUE_WORK:
                question_num.setVisibility(View.GONE);
                right_arrow.setVisibility(View.GONE);
                customViewHold.getRoorView().setEnabled(false);
                break;
            case WORK_REPORT:
                question_num.setVisibility(View.VISIBLE);
                right_arrow.setVisibility(View.VISIBLE);
                customViewHold.getRoorView().setEnabled(true);
                break;
        }

        if (!TextUtils.isEmpty(item.getTotalNums())) {
            question_num.setText(item.getTotalNums() + "题");
        }

        if (!TextUtils.isEmpty(item.getConstructName())) {
            questionType.setText(item.getConstructName());
        }

        if (!TextUtils.isEmpty(item.getSchedule())) {
            questionStatus.setText(item.getSchedule());
        }


        customViewHold.getRoorView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (listener != null) {
                    listener.onClick(position);
                }
            }
        });

    }
}
